]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
weather: Track whether a location was set
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 19 Mar 2017 13:42:35 +0000 (14:42 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 20 Mar 2017 18:02:08 +0000 (19:02 +0100)
Setting GWeatherInfo:location to null helpfully doesn't mean
"no location", but "NYC". This obviously isn't what we want
to show users, so track the location validity separately and
consider it when updating the label shown to users.

https://bugzilla.gnome.org/show_bug.cgi?id=780252

js/misc/weather.js
js/ui/dateMenu.js

index 36346adbcfbfc8c1b1cb366bb8cc7ea0c68f9797..775d053011dd210ae473a01c5518b6b2650ca039 100644 (file)
@@ -17,6 +17,7 @@ const WeatherClient = new Lang.Class({
 
     _init: function() {
         this._loading = false;
+        this._locationValid = false;
         this._lastUpdate = GLib.DateTime.new_from_unix_local(0);
 
         this._useAutoLocation = false;
@@ -55,6 +56,10 @@ const WeatherClient = new Lang.Class({
         return this._loading;
     },
 
+    get hasLocation() {
+        return this._locationValid;
+    },
+
     get info() {
         return this._weatherInfo;
     },
@@ -64,6 +69,9 @@ const WeatherClient = new Lang.Class({
     },
 
     update: function() {
+        if (!this._locationValid)
+            return;
+
         let now = GLib.DateTime.new_now_local();
         // Update without loading indication if the current info is recent enough
         if (this._weatherInfo.is_valid() &&
@@ -101,6 +109,7 @@ const WeatherClient = new Lang.Class({
 
         this._weatherInfo.abort();
         this._weatherInfo.set_location(location);
+        this._locationValid = (location != null);
 
         if (location)
             this._loadInfo();
index eec19857d3b36f5a484548b6ff389bd3a3c532db..18b5b0b4fa7f44af114ffec6d82b2c6c46ccc300 100644 (file)
@@ -296,6 +296,9 @@ const WeatherSection = new Lang.Class({
     },
 
     _getLabelText: function() {
+        if (!this._weatherClient.hasLocation)
+            return _("Select a location…");
+
         if (this._weatherClient.loading)
             return _("Loading…");